/**
 * Created by Administrator on 2017/4/1.
 */
"use strict";
swan_pc
    .controller("PersonalOppPartnerController",function($scope,$rootScope,$state,oppPartner,oppDecision) {

        $scope.getPartner = function () {
            oppPartner.query({id: $rootScope.opp.id}, function (result) {
                $scope.partner = result;
                console.log('PARTNER:', $scope.partner);
                // $scope.setStruct();
            })
        };

        $scope.setList=function () {
            $scope.possibilityList=[
                {
                    name:'低价格',
                    value:1
                },
                {
                    name:'设定技术标准',
                    value:2
                },
                {
                    name:'耍流氓',
                    value:3
                },
                {
                    name:'利用资质优势',
                    value:4
                },
                {
                    name:'建立同盟',
                    value:5
                },
                {
                    name:'赠送',
                    value:6
                },
                {
                    name:'特殊服务',
                    value:7
                },
                {
                    name:'我不清楚',
                    value:8
                },
            ];
            $scope.reasonList=[
                {
                    name:'高层支持',
                    value:1
                },
                {
                    name:'人际关系',
                    value:2
                },
                {
                    name:'性价比',
                    value:3
                },
                {
                    name:'产品',
                    value:4
                },
                {
                    name:'价格',
                    value:5
                },
                {
                    name:'使用惯性',
                    value:6
                },
                {
                    name:'我不清楚',
                    value:7
                }
            ];
            $scope.knowList=[
                {
                    name:'很了解',
                    value:1
                },
                {
                    name:'了解',
                    value:2
                },
                {
                    name:'有点了解',
                    value:3
                },
                {
                    name:'不太了解',
                    value:4
                },
                {
                    name:'一无所知',
                    value:5
                }
            ];
            $scope.advantageList=[
                {
                    name:'高层支持',
                    value:1
                },
                {
                    name:'人际关系',
                    value:2
                },
                {
                    name:'性价比',
                    value:4
                },
                {
                    name:'产品',
                    value:8
                },
                {
                    name:'价格',
                    value:16
                },
                {
                    name:'使用惯性',
                    value:32
                },
                {
                    name:'我不清楚',
                    value:64
                },
            ];
            $scope.shortcomingList=[
                {
                    name:'高层不支持',
                    value:1
                },
                {
                    name:'人际关系',
                    value:2
                },
                {
                    name:'性价比',
                    value:4
                },
                {
                    name:'产品',
                    value:8
                },
                {
                    name:'价格',
                    value:16
                },
                {
                    name:'使用惯性',
                    value:32
                },
                {
                    name:'我不清楚',
                    value:64
                },
            ];
            $scope.strategyList=[
                {
                    name:'低价格',
                    value:1
                },
                {
                    name:'设定技术标准',
                    value:2
                },
                {
                    name:'耍流氓',
                    value:4
                },
                {
                    name:'利用资质优势',
                    value:8
                },
                {
                    name:'建立同盟',
                    value:16
                },
                {
                    name:'赠送',
                    value:32
                },
                {
                    name:'特殊服务',
                    value:64
                },
                {
                    name:'我不清楚',
                    value:128
                },
            ];
            $scope.informationList=[
                {
                    name:'能',
                    value:1
                },
                {
                    name:'不能',
                    value:2
                },
                {
                    name:'我不清楚',
                    value:3
                }
            ];
            $scope.timelyList=[
                {
                    name:'是的',
                    value:1
                },
                {
                    name:'凑合',
                    value:2
                },
                {
                    name:'不太及时',
                    value:3
                },
                {
                    name:'我不清楚',
                    value:4
                }
            ];
            $scope.seniorList=[
                {
                    name:'资深',
                    value:1
                },
                {
                    name:'相对资深',
                    value:2
                },
                {
                    name:'嫩',
                    value:3
                },
                {
                    name:'我不清楚',
                    value:4
                },
            ];
            $scope.reliableList=[
                {
                    name:'可靠',
                    value:1
                },
                {
                    name:'相对可靠',
                    value:2
                },
                {
                    name:'油滑',
                    value:3
                },
                {
                    name:'我不清楚',
                    value:4
                },
            ];
            $scope.roleList=[
                {
                    name:'技术关键人',
                    value:1
                },
                {
                    name:'商务关键人',
                    value:2
                },
                {
                    name:'联络人',
                    value:3
                },
                {
                    name:'其他参与人',
                    value:4
                }
            ];
            $scope.bidModeList=[
                {
                    name:'自有产品投标',
                    value:1
                },
                {
                    name:'代理产品投标',
                    value:2
                },
                {
                    name:'自有产品同时代理产品投标',
                    value:3
                },
                {
                    name:'供应产品不直接投标',
                    value:4
                },
                {
                    name:'中间过手',
                    value:5
                }
            ]
        };
        $scope.setList();
        $scope.getPartner();

        $scope.setStruct=function () {
            $scope.partnerStruct=[
                {
                    blockName: '基本信息',
                    blockKey: 'base',
                    type: 'normal',
                    list: [],
                    struct: [
                        {
                            name:'其取胜可能性',
                            key:'possibility',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.possibilityList,
                            numInRow: 2,
                        },
                        {
                            name:'可能取胜的关键原因',
                            key:'reason',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.reasonList,
                            numInRow:2,
                        },
                        {
                            name:'对其方案了解程度',
                            key:'program',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.knowList,
                            numInRow:2,
                        },
                        {
                            name:'对其价格了解程度',
                            key:'price',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.knowList,
                            numInRow:2,
                        },
                        {
                            name:'其优势',
                            key:'advantage',
                            type:3,
                            preText:'',
                            afterText:'',
                            select:$scope.advantageList,
                            numInRow:2,
                        },
                        {
                            name:'其劣势',
                            key:'shortcoming',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.shortcomingList,
                            numInRow:2,
                        },
                        {
                            name:'其竞争策略',
                            key:'strategy',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.possibilityList,
                            numInRow:2,
                        },
                        {
                            name:'竞争对手参与投标方式',
                            key:'bidMode',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.bidModeList,
                            numInRow:2,
                        }
                    ]
                },
                {
                    blockName: '支持者',
                    blockKey: 'supporters',
                    type: 'repeatOnly',
                    list: [],
                    struct: [
                        {
                            name:'支持者',
                            key:'decisionMaker',
                            type: 4,
                            preText: '',
                            afterText: '',
                            select: [],
                            numInRow: 1,
                        },
                        {
                            name:'对手能从此人获得有价值信息',
                            key:'information',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.informationList,
                            numInRow:2,
                        },
                        {
                            name:'对手所获得的信息是及时的',
                            key:'timely',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.timelyList,
                            numInRow:2,
                        },
                        {
                            name:'',
                            key:'',
                            type:0,
                            preText:'',
                            afterText:'',
                            select:[],
                            numInRow:1,
                        }
                    ]
                },
                {
                    blockName: '参与人',
                    blockKey: 'participants',
                    type: 'repeatOnly',
                    list: [],
                    struct: [
                        {
                            name: '参与人',
                            key: 'userContact',
                            type: 4,
                            preText: '',
                            afterText: '',
                            select: [],
                            numInRow: 1,
                        },
                        {
                            name: '此人身份',
                            key: 'role',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select: $scope.roleList,
                            numInRow: 2,
                        },
                        {
                            name:'此人资深程度',
                            key:'senior',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select: $scope.seniorList,
                            numInRow: 2,
                        },
                        {
                            name:'此人可靠程度',
                            key:'reliable',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select: $scope.reliableList,
                            numInRow: 2,
                        },
                        {
                            name:'他会直接得到信息',
                            key:'direct',
                            type: 5,
                            preText: '',
                            afterText: '',
                            select: [],
                            numInRow: 2,
                        }
                    ]
                }
            ]
        }

        $scope.selectPartner=function (partner) {
            $scope.show=true;
            $scope.selectedPartner=partner;
            $scope.partnerPoint={
                base:partner,
                supporters:partner.supporters,
                participants:partner.participants
            }
            $scope.setStruct();
        }
    })